package org.example.controller;

import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.example.entity.ClassQuestion;
import org.example.service.ClassQuestionService;
import org.example.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName ClassQuestionController
 * @Description TODO
 * @Author qiuye
 * @Date 2025年08月18日 16:00
 * @Version 1.0
 */
@RestController
@RequestMapping("question")
public class ClassQuestionController {
    @Autowired
    private ClassQuestionService classQuestionService;
    @GetMapping("page")
    public R getQuestionPage(ClassQuestion classQuestion,
                             @RequestParam(required = false,defaultValue = "1") int page,
                             @RequestParam(required = false,defaultValue = "5")int size) {
        PageInfo<ClassQuestion> classQuestion1 = classQuestionService.getClassQuestion(classQuestion, page, size);
        return R.ok(classQuestion1);
    }
    @GetMapping("count")
    public R getQuestionCount(ClassQuestion classQuestion,
                              @RequestParam(required = false,defaultValue = "1") int page,
                              @RequestParam(required = false,defaultValue = "5")int size) {
        PageInfo<ClassQuestion> classQuestionCount = classQuestionService.getClassQuestionCount(classQuestion, page, size);
        return R.ok(classQuestionCount);
    }
    @GetMapping("hui")
    public R gettQuestionHui(ClassQuestion classQuestion,
                             @RequestParam(required = false,defaultValue = "1") int page,
                             @RequestParam(required = false,defaultValue = "5")int size){
        PageInfo<ClassQuestion> classQuestionHui = classQuestionService.getClassQuestionHui(classQuestion, page, size);
        return R.ok(classQuestionHui);
    }
}
